import { SUCCESS, FAILURE } from '../constants';
import Action from '../core/Action';
import Tick from '../core/Tick';

export default abstract class Switch extends Action {

  constructor(name = 'Switch') {
    super(name);
  }

  onTick(tick: Tick, ...args: any[]): number {
    return this.onConsume(tick, ...args) ? this.defauleTrueType() : this.defaultFalseType()
  }

  abstract onConsume(tick: Tick, ...args: any[]): boolean

  defauleTrueType() {
    return SUCCESS
  }

  defaultFalseType() {
    return FAILURE
  }
};
